package com.angel.arquitectura.service.impl.user;

import com.angel.arquitectura.dao.factory.ArquitecturaDAOFactory;
import com.angel.arquitectura.exception.BusinessException;
import com.angel.arquitectura.model.user.User;
import com.angel.arquitectura.service.impl.GenericServiceImpl;
import com.angel.arquitectura.service.user.UserService;
import org.apache.log4j.Logger;

public class UserServiceImpl extends GenericServiceImpl implements UserService {

    private static Logger LOGGER = Logger.getLogger(UserServiceImpl.class);

	public User findUserByName(String userName) {
        User user = ArquitecturaDAOFactory.createInstance().getUserDAO().findUniqueByUserName(userName);

        if(user == null){
            LOGGER.error("No se encontro el usuario [" + userName + "].");
			throw new BusinessException("No se encontro el usuario.");
		}
		return user;
	}
}